import NProgress from 'nprogress'
import 'nprogress/nprogress.css'
import { defineAsyncComponent } from 'vue'
import loadingVue from '@/components/loading/index.vue'
export function getAsyncPage(componentFn) {
    return async () => {
        NProgress.start()
        const component = await componentFn()
        NProgress.done()
        return component
    }
}

var test
// 异步组件
export function getAsyncComponent(importFn) {
    // 延迟加载
    return defineAsyncComponent({
        loader: async () => {
            return importFn()
        },
        loadingComponent: loadingVue
    })
}




async function delay(ms) {
    return new Promise(resolve => setTimeout(resolve, ms))
}